package com.hejun.book.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hejun.book.dao.BookDao;
import com.hejun.book.entity.Book;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class ServiceBook {
    @Resource
    BookDao bookDao;



    public boolean add(Book book) {
        return bookDao.insert(book)>0;
    }

    public PageInfo<Book> getPage(Integer pageNum) {
        PageHelper.startPage(pageNum,3,"id asc");
        List<Book> books = bookDao.queryAllBy(new Book());
        PageInfo<Book> bookPageInfo = new PageInfo<>(books);
        return bookPageInfo;
    }
}
